#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
string s = "123456789abcdefghijklmnopqrstuvwxyz";
void n_to_m(int n,int m)
{
	if (n>=m)
	    n_to_m(n/m,m);
	cout << s[n%m];
}


int main()
{
   int n,m;
   cin >> n >> m;
   n_to_m(n,m);

}
